package com.thinkgem.jeesite.modules.sys.utils;

import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import com.thinkgem.jeesite.modules.bookset.dao.BkPlaceDao;
import com.thinkgem.jeesite.modules.bookset.entity.BkPlace;
import com.thinkgem.jeesite.modules.shelf.dao.BkShelfDao;
import com.thinkgem.jeesite.modules.shelf.entity.BkShelf;

import java.util.ArrayList;
import java.util.List;

/**
 * PublisherUtils
 * Created by aulbrother on 2015/12/21.
 */
public class StoreUtils{
    private static BkPlaceDao bkPlaceDao = SpringContextHolder.getBean(BkPlaceDao.class);
    private static BkShelfDao bkShelfDao = SpringContextHolder.getBean(BkShelfDao.class);
    public static List<BkPlace> getStoreList(){
        return bkPlaceDao.findAll();
    }

    //获取所有书库列表
    public static List<BkPlace> getAllStoreList(boolean hasHead){

        List<BkPlace> all = new ArrayList<>();
        if(hasHead){
            BkPlace bkPlace = new BkPlace();
            bkPlace.setId("");
            bkPlace.setGcdName("全部");
            all.add(bkPlace);
        }

        List<BkPlace> list = bkPlaceDao.findAllStoreList();

        all.addAll(list);
        return all;
    }

    //获取所有书架号列表对象
    public static  List<BkShelf> getAllShelfList(boolean hasHead){
        List<BkShelf> all = new ArrayList<>();
        if(hasHead){
            BkShelf bkShelf = new BkShelf();
            bkShelf.setId("");
            bkShelf.setName("全部");
            all.add(bkShelf);
        }
        List<BkShelf> list = bkShelfDao.findAllList(new BkShelf());
        all.addAll(list);
        return all;
    }

}
